import { Button, NavBar, Tabs } from 'antd-mobile'
import React, { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
// import { getListApi } from '../../api'
import utils from '../../utils/http'

const List = () => {
    const nav = useNavigate()
    const { state } = useLocation()
    const { start, end } = state
    console.log(start, end);
    const [list, setList] = useState([])
    const [page, setPage] = useState(0)

    const getData = async () => {
        //    const resp=await getListApi(data)
        const resp = await utils.post("/trip/train", { start, end, page })
        console.log(resp.data.data, 1111);
        setList([...list, ...resp.data.data])
        setPage(page + 1)
    }
    useEffect(() => {
        getData()
    }, [])



    const date = [
        '2025-5-13',
        '2025-5-14',
        '2025-5-15',
        '2025-5-16',
        '2025-5-17',
        '2025-5-18',
        '2025-5-19',
    ]

    
    return (
        <div>
            <NavBar onBack={() => nav(-1)}>{state.start}——{state.end}</NavBar>
            <div style={{
                display: 'flex',
                justifyContent: 'space-between'
            }}>
                <Button color='primary' fill='solid'>
                前一天
            </Button>
            <Tabs>
                {
                    date.map((v, i) => {
                        return <Tabs.Tab title={v.title} key={i}>
                            {v}
                        </Tabs.Tab>
                    })
                }
            </Tabs>
            <Button color='primary' fill='solid'>
                后一天
            </Button>
            </div>
            
            {
                list.map((v, i) => {
                    return <dl key={i}>
                        <dt>
                            <div>{v.start}-{v.end}</div>
                        </dt>
                    </dl>
                })
            }

        </div>
    )
}

export default List
